/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ericsson.nfc.signing.algorithm;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.DERObject;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;

/**
 *
 * @author emarkki
 */
public class PrivateKey {
    
    private PrivateKeyInfo privateKeyInfo;
    private DERObject object;

    public PrivateKey(byte[] bytes) throws IOException {
        this(new ByteArrayInputStream(bytes));
    }
    
    public PrivateKey(InputStream in) throws IOException {
        ASN1InputStream aIn = new ASN1InputStream(in);
        object = aIn.readObject();
    }
    
    public PrivateKeyInfo getPrivateKeyInfo() {
        privateKeyInfo = PrivateKeyInfo.getInstance(object);
        return privateKeyInfo;
    }
        
}
